package com.nf;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * Hello world!
 *
 */
public class App2 {

    public static Connection getConnection()throws Exception{
        Class.forName("com.mysql.cj.jdbc.Driver");
        return DriverManager.getConnection("jdbc:mysql://localhost:3306/test001?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true","root","123456");
    }

    public static void main( String[] args ) throws Exception{
        long start_time = System.currentTimeMillis();

        for (int i=0;i<1000;i++) {
            Connection c1 = getConnection();
            Connection c2 = getConnection();
            Connection c3 = getConnection();
            c1.close();
            c2.close();
            c3.close();
        }

        long end_time = System.currentTimeMillis();

        System.out.println("耗时："+ (end_time-start_time) +"毫秒");






    }
}
